home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
-
- // Synopsis: Vandermonde matrix.
-
- // Syntax: V = vand ( P )
- // V = vand ( M , P )
-
- // Descriptioin:
-
- // V = vand(P), where P is a vector, produces the (primal)
- // Vandermonde matrix based on the points P, i.e.
- // V[i;j] = P[j]^(i-1).
-
- // vand ( M , P ) is a rectangular version of VAND(P) with M
- // rows. Special case: If P is a scalar then P equally spaced
- // points on [0,1] are used.
-
- // Reference:
- // N.J. Higham, Stability analysis of algorithms for solving
- // confluent Vandermonde-like systems, SIAM J. Matrix Anal. Appl.,
- // 11 (1990), pp. 23-41.
-
- // This file is a translation of vand.m from version 2.0 of
- // "The Test Matrix Toolbox for Matlab", described in Numerical
- // Analysis Report No. 237, December 1993, by N. J. Higham.
-
- // Dependencies
- require seqa
-
- //-------------------------------------------------------------------//
-
- vand = function ( m , p )
- {
- local (m, p)
-
- if (!exist (p)) { p = m; narg = 1; else narg = 2; }
- n = max(size(p));
-
- // Handle scalar p.
- if (n == 1)
- {
- n = p;
- p = seqa(0,1,n);
- }
-
- if (narg == 1) { m = n; }
-
- p = p[:].'; // Ensure p is a row vector.
- V = ones(m,n);
- for (i in 2:m)
- {
- V[i;] = p.*V[i-1;];
- }
-
- return V;
- };
-